<?php

/**
 * Contact form base class.
 *
 * @method Contact getObject() Returns the current form's model object
 *
 * @package    Porba
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseContactForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'contact_code'   => new sfWidgetFormInputText(),
      'name'           => new sfWidgetFormInputText(),
      'contact_person' => new sfWidgetFormInputText(),
      'address'        => new sfWidgetFormInputText(),
      'zipcode'        => new sfWidgetFormInputText(),
      'city'           => new sfWidgetFormInputText(),
      'country'        => new sfWidgetFormInputText(),
      'phone'          => new sfWidgetFormInputText(),
      'mobile'         => new sfWidgetFormInputText(),
      'fax'            => new sfWidgetFormInputText(),
      'email'          => new sfWidgetFormInputText(),
      'website'        => new sfWidgetFormInputText(),
      'bank'           => new sfWidgetFormInputText(),
      'bank_account'   => new sfWidgetFormInputText(),
      'IBAN'           => new sfWidgetFormInputText(),
      'BIC'            => new sfWidgetFormInputText(),
      'VAT'            => new sfWidgetFormInputText(),
      'category_name'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CategoryContact'), 'add_empty' => false)),
      'note'           => new sfWidgetFormTextarea(),
      'created_at'     => new sfWidgetFormDateTime(),
      'updated_at'     => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'contact_code'   => new sfValidatorString(array('max_length' => 255)),
      'name'           => new sfValidatorString(array('max_length' => 255)),
      'contact_person' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'address'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'zipcode'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'city'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'country'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'phone'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'mobile'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'fax'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'email'          => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'website'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'bank'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'bank_account'   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'IBAN'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'BIC'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'VAT'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'category_name'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('CategoryContact'))),
      'note'           => new sfValidatorString(array('max_length' => 4000, 'required' => false)),
      'created_at'     => new sfValidatorDateTime(),
      'updated_at'     => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Contact', 'column' => array('contact_code')))
    );

    $this->widgetSchema->setNameFormat('contact[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contact';
  }

}
